﻿using System.Windows;
using System.Windows.Input;

namespace MDCAdminTool.Commands
{
    public class ConfigCacheCluster : CommandBinding
    {
        public ConfigCacheCluster()
        {
            Command = Application.Current.Resources["ConfigCacheCluster"] as ICommand;
            Executed += OnExecuted;
            CanExecute += OnCanExecute;
        }

        protected void OnExecuted( object sender , ExecutedRoutedEventArgs e )
        {
            var cluster = e.Parameter as CacheCluster;
			if (cluster == null)
			{
				var @base = e.Parameter as GroupBase;
				if (@base != null)
				{
					cluster = @base.Cluster;
				}
				else
				{
					return;
				}
			}

            if ( cluster != null )
            {
                App.NewTab();
            }
        }
        protected void OnCanExecute( object sender , CanExecuteRoutedEventArgs e )
        {
            e.CanExecute = true;
        }
    }
}